//
//  HALoginNavView.m
//  RedGrass
//
//  Created by wukong on 2018/11/23.
//  Copyright © 2018年 hongcaosp. All rights reserved.
//

#import "HALoginNavView.h"

@interface HALoginNavView()

@property (strong, nonatomic) UIButton *backBtn;
@property (strong, nonatomic) UIButton *passLoginBtn;

@end

@implementation HALoginNavView

-(instancetype) initWithFrame:(CGRect)frame{
    if(self = [super initWithFrame:frame]){
        [self addSubview:self.backBtn];
        [self addSubview:self.passLoginBtn];
        [self addMasonry];
    }
    return self;
}

-(void) addMasonry{
    [_backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self).mas_offset(24);
        make.centerY.mas_equalTo(self).mas_offset(0);
    }];
    [_passLoginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self).mas_offset(-20);
        make.centerY.mas_equalTo(self).mas_offset(0);
    }];
}


#pragma mark - response

-(void)backBtnClick:(UIButton *)button{
    if(self.backBlock){
        self.backBlock();
    }
}

-(void)passLoginBtnClick:(UIButton *)button{
    if(self.passwordLoginBlock){
        self.passwordLoginBlock();
    }
}

#pragma mark - getter
-(UIButton *)backBtn{
    if(!_backBtn){
        _backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_backBtn setImage:IMAGE_NAMED(@"关闭") forState:UIControlStateNormal];
        [_backBtn addTarget:self action:@selector(backBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        _backBtn.tag = 1000;
    }
    return _backBtn;
}

-(UIButton *)passLoginBtn{
    if(!_passLoginBtn){
        _passLoginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_passLoginBtn setTitle:@"密码登录" forState:UIControlStateNormal];
        [_passLoginBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_passLoginBtn.titleLabel setFont:FONT(customFontName, 14)];
        [_passLoginBtn addTarget:self action:@selector(passLoginBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _passLoginBtn;
}

@end
